<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"         
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <h:body>

        <ui:composition template="./../templates/templateNECS.xhtml">

            <ui:define name="top">
                Criar uma venda
            </ui:define>

            <ui:define name="left">            
                <h:outputLink value="funcBalc_venda_listar.xhtml">Lista de Vendas</h:outputLink>
                <br></br>
                <h:outputLink value="funcBalc_venda_criar.xhtml">Criar Venda</h:outputLink>
            </ui:define>

            <ui:define name="content">
                <h:form> 
                        <h:outputLabel for="id" value="Id:" />
                        <h:inputText 
                            id="id"
                            size="12"
                            required="true"
                            requiredMessage="Erro: Deve inserir um id."
                            value="#{funcionarioBalcaoManager.vendaNova.id}" />
                        <h:message for="id" errorStyle="color: red" />    
                        
                        <h:outputText value="&#160;" />
                        <h:outputText value="&#160;" />
                        <h:outputText value="&#160;" />
                        <h:outputText value="&#160;" />
                        <h:outputText value="&#160;" />
                        <h:outputText value="&#160;" />
                        <h:outputText value="&#160;" />
                        <h:outputText value="&#160;" />
                        
                        <h:outputLabel for="Data" value="Data:" />
                        <p:calendar 
                            id="data"
                            size="12"
                            required="true"
                            requiredMessage="Erro: Deve inserir uma data."
                            value="#{funcionarioBalcaoManager.vendaNova.dataVenda}" />
                        <h:message for="data" errorStyle="color: red" />
                        
                    <h:dataTable var="linhaVenda"
                                 summary="Tabela de linhas de venda"
                                 value="#{funcionarioBalcaoManager.vendaNova.listaLinhasVenda}"
                                 rules="all"
                                 cellpadding="5">
                        <f:facet name="header">
                            <h:outputText value="Produtos" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:outputText value="&#160;" />
                            <h:button value="+" outcome="funcBalc_produto_catalogo_adicionar.xhtml" />                            
                        </f:facet>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Referência" />
                            </f:facet>
                            <h:outputText value="#{linhaVenda.produtoCatalogo.referencia}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Nome do produto" />
                            </f:facet>
                            <h:outputText value="#{linhaVenda.produtoCatalogo.nome}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Quantidade" />
                            </f:facet>
                            <h:outputText value="#{linhaVenda.quantidade}" />
                        </h:column>
                    </h:dataTable>
                    <h:commandButton
                            id="CriarVenda"
                            binding="#{funcionarioBalcaoManager.componente}"
                            value="Criar Venda"
                            action="#{funcionarioBalcaoManager.criarVenda()}">
                        <f:setPropertyActionListener target="#{funcionarioBalcaoManager.vendaAtual}" value="#{funcionarioBalcaoManager.vendaNova}" />
                    </h:commandButton>
                    
                        <h:message for="submit" style="color: red"/>   
                    <br />  
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>
